package com.jr.Assess_java.service;

import com.alibaba.fastjson.JSONObject;
import com.jr.Assess_java.Constans;
import com.jr.Assess_java.bean.HotVideo;
import com.jr.Assess_java.bean.HotVideoCommon;
import com.jr.Assess_java.request.HttpUtils;

import java.util.List;

/**
 * @author:xhh
 * @email:3231954428@qq.com
 * @desc:
 * @datatime:2021/12/7 15:12
 */
public class HotVideoService {
    /**
     * 该函数用于获取热门视频数据
     *
     * */
    public static List<HotVideo> getVideoService() {
        String url = Constans.url
                + "?key=" + Constans.key
                + "&type=hot_video"
                + "&size=20";
        String result = HttpUtils.get(url);
        System.out.println(result);

        //json解析
        HotVideoCommon hotVideoCommon = JSONObject.parseObject(result, HotVideoCommon.class);

        return hotVideoCommon.result;
    }
}
